//
//  EmptyDataView.swift
//  test-ios
//
//  Created by wyz5204 on 2023/7/2.
//

import Foundation
import UIKit


class EmptyDataView : UIAbstractView{
    
    private lazy var bt = {
        return UIButton().then { view in
            view.setTitleAndColor("点击刷新")
        }
    }()
    
    private var callback :  ((EmptyDataView) -> Void)? = nil
    
    func setCallback (_ callback : @escaping  (EmptyDataView) -> Void ) -> EmptyDataView{
        self.callback = callback
        return self
    }
    
    override func initView(_ frame: CGRect) {
        
        backgroundColor = .black.withAlphaComponent(0.05)
        
        bt.addTo(self) { view in
            view.snp.makeConstraints { make in
                make.center.equalToSuperview()
            }
        }
        
        bt.rx.tap.asDriver().drive(onNext: { [weak self] in
            // 通知到外界 进行刷新
            self?.showToast(" 刷新 ...... ")
            
            self?.callback?(self!)
        }).disposed(by: rx.disposeBag)
    }
    
}
